package net.lijingye.education.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import net.lijingye.education.entity.Lesson;

import java.text.DecimalFormat;

/**
 * Created by LijingYe on 2016/3/26.
 */
public class LessonLiteVO {
    @JSONField(name = "id", ordinal = 0, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String id;
    @JSONField(name = "name", ordinal = 1, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String name;
    @JSONField(name = "term", ordinal = 2, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String term;
    @JSONField(name = "credit", ordinal = 3, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String credit;
    @JSONField(name = "weekTime", ordinal = 4, serialzeFeatures = SerializerFeature.WriteMapNullValue)
    private String weekTime;

    public LessonLiteVO(Lesson lesson) {
        this.id = lesson.getId();
        this.name = lesson.getCourse().getName();
        this.term = lesson.getTerm().getName();
        DecimalFormat decimalFormat = new DecimalFormat("#.0");
        this.credit = decimalFormat.format(lesson.getCourse().getCredit());
        this.weekTime = decimalFormat.format(lesson.getCourse().getWeekTime());
    }

    public LessonLiteVO(String id, String name, String term, String credit, String weekTime) {
        this.id = id;
        this.name = name;
        this.term = term;
        this.credit = credit;
        this.weekTime = weekTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTerm() {
        return term;
    }

    public void setTerm(String term) {
        this.term = term;
    }

    public String getCredit() {
        return credit;
    }

    public void setCredit(String credit) {
        this.credit = credit;
    }

    public String getWeekTime() {
        return weekTime;
    }

    public void setWeekTime(String weekTime) {
        this.weekTime = weekTime;
    }

    @Override
    public String toString() {
        return "LessonLiteVO{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", term='" + term + '\'' +
                ", credit='" + credit + '\'' +
                ", weekTime='" + weekTime + '\'' +
                '}';
    }
}
